package main

import (
	"database/sql"
	"fmt"
	//"time"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	db, err := sql.Open("mysql", "root:123321@tcp(11.22.33.44:3306)/test?charset=utf8")
	checkErr(err)

	//查询数据
	rows, err := db.Query("SELECT ID,nickname,phone,remark FROM user")
	checkErr(err)

	for rows.Next() {
		var id int
		var nickname string
		var phone string
		var remark string
		err = rows.Scan(&id, &nickname, &phone, &remark)
		checkErr(err)
		fmt.Println(id)
		fmt.Println(nickname)
		fmt.Println(phone)
		fmt.Println(remark)
	}

	db.Close()

}

func checkErr(err error) {
	if err != nil {
		panic(err)
	}
}
